#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable:6031)


class Solution {
public:
    string convert(string s, int numRows) {
        if (numRows == 1)
            return s;
        else {
            string ans;
            int len = s.size();
            for (int j = 0; j < numRows; j++) {
                for (int i = 0; i < len; i++) {
                    if (i % (2 * numRows - 2) == j || i % (2 * numRows - 2) == 2 * numRows - 2 - j) {
                        ans += s[i];
                    }
                }
            }
            return ans;
        }

    }
};

